package com.JackTang.fruit.service.impl;

import com.JackTang.fruit.service.FruitService;
import com.JackTang.fruit.dao.FruitDAO;
import com.JackTang.fruit.dao.impl.FruitDAOImpl;
import com.JackTang.fruit.pojo.Fruit;

import java.util.List;

/**
 * @author Jack Tang
 * @description
 * @create 2023-05-11 22:17
 */
public class FruitServiceImpl implements FruitService {

    private FruitDAO fruitDAO = null;

    @Override
    public List<Fruit> getFruitList(String keyword, Integer pageNo) {
        return fruitDAO.getFruitList(keyword, pageNo);
    }

    @Override
    public void addFruit(Fruit fruit) {
        fruitDAO.addFruit(fruit);
    }

    @Override
    public Fruit getFruitById(Integer id) {
        return fruitDAO.getFruitByFid(id);
    }

    @Override
    public void delFruit(Integer fid) {
        fruitDAO.deleteFruit(fid);
    }

    @Override
    public Integer getPageCount(String keyword) {
        int count = fruitDAO.getFruitCount(keyword);
        int pageCount = (count+5-1)/5;
        return pageCount;
    }

    @Override
    public void updateFruit(Fruit fruit) {
        fruitDAO.updateFruit(fruit);
    }
}